#include "otherthread.h"

#include <QDebug>

OtherThread::OtherThread(QObject *parent) : QObject(parent)
{

}

OtherThread::~OtherThread()
{
    qInfo() << "[OTHER] Thread Release Resources";
}

void OtherThread::startThread_slot()
{
    qInfo() << "[OTHER] Thread Start";

    QTimer *m_timer = new QTimer;
    connect(m_timer, &QTimer::timeout, this, &OtherThread::onSelect_slot);
    m_timer->start(1000);
}

void OtherThread::exitThread_slot()
{
    qInfo() << "[OTHER] Thread Exit";
}

void OtherThread::onSelect_slot()
{
    qDebug() << "[OTHER] On Select Slot";

    int ret = 0;
    int all = 0;
    int valid = 0;
    int upload = 0;

    // Select DR Data
    ret = database.drDataOtherSelect(all, valid, upload, m_id);
    if (ret != 0)
    {
        qWarning() << "[OTHER] DR Data Select Failed" << ret;
        return;
    }

    m_id = all;

    emit sendProgress_signal(all, valid, upload);
    qInfo() << "[OTHER] DR Data Select All" << all
            << "Valid" << valid << "Upload" << upload;
}
